package basic.socket.udp;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * @author bingo
 * @Description   //键盘录入
 * @Date 2018/7/18
 */
public class DatagramSocketClient2 {

    public static void main(String[] args) throws Exception {

        DatagramSocket ds = new DatagramSocket();

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        byte[] data;
        String line;
        while ((line=bufferedReader.readLine())!=null){
            data = line.getBytes();
            DatagramPacket dp = new DatagramPacket(data,data.length, InetAddress.getByName("127.0.0.1"),8888);
            ds.send(dp);
        }
        ds.close();
    }
}
